
import 'package:flutter/material.dart';
import 'package:juju/control/JmessageCtl.dart';

class WelcomePage extends StatefulWidget {
  const WelcomePage({Key? key}) : super(key: key);

  @override
  State<WelcomePage> createState() => _WelcomePageState();
}

class _WelcomePageState extends State<WelcomePage> {
  TextEditingController? _usernameTextController;
  TextEditingController? _passwordTextController;

  @override
  void initState() {
    super.initState();
    _usernameTextController = TextEditingController();
    _passwordTextController = TextEditingController();
  }

  @override
  Widget build(BuildContext context) {
    // print(context);
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.fromLTRB(30.0, 10.0, 30.0, 10.0),
              child: TextField(
                controller: _usernameTextController,
                decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: "账号",
                ),
              ),
            ),
            Padding(
              // padding: EdgeInsets.all(10.0),
              padding: const EdgeInsets.fromLTRB(30.0, 10.0, 30.0, 10.0),
              child: TextField(
                controller: _passwordTextController,
                obscureText: true,
                decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: "密码",
                ),
              ),
            ),
            Padding(
              // padding: EdgeInsets.all(10.0),
              padding: const EdgeInsets.fromLTRB(50.0, 50.0, 50.0, 10.0),
              child: Row(
                children: <Widget>[
                  Expanded(
                    child: FloatingActionButton(
                      foregroundColor: Colors.blue[300],
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(50.0),
                      ),
                      onPressed: () => allInOne(_usernameTextController!.text,
                          _passwordTextController!.text, context),
                      child: const Text(
                        "登录/注册",
                        style: TextStyle(color: Colors.white),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
